using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using Microsoft.VisualStudio.DebuggerVisualizers;
using System.Collections;

namespace TestCustomDV
{
    class Program
    {
        static void Main(string[] args)
        {
            PeopleContainer pc = new PeopleContainer();

            pc.AddPerson(new Person("John", 10));
            pc.AddPerson(new Person("Jim", 10));
            pc.AddPerson(new Person("Tom", 10));
            pc.AddPerson(new Person("Harry", 10));

            int idx = 0;
        }
    }

    [DebuggerVisualizer(typeof(MyDV))]
    [Serializable]
    public class PeopleContainer
    {
        private List<Person> _people = new List<Person>();
        public List<Person> People { get { return _people; } }
        public void AddPerson(Person person) { _people.Add(person); }
        public Person NewPerson() { return new Person(); }
    }

    [Serializable]
    public class Person
    {
        private int _age;
        private string _name;

        public Person() { }
        public Person(string name, int age)
        {
            _name = name;
            _age = age;
        }

        public string Name
        {
            get { return _name; }
            set { _name = value; }
        }

        public int Age
        {
            get { return _age; }
            set { _age = value; }
        }

        public int YearBorn { get { return DateTime.Today.Year - Age; } }
    }

    public class MyDV : PoSHVisualizer.PoSHVisualizer
    {
        protected override void Show(IDialogVisualizerService windowService, IVisualizerObjectProvider objectProvider)
        {
            SetVariable("p", new Person());
            SetVariable("dv", this);

            List<int> items = new List<int>();
            items.Add(1);
            items.Add(2);
            items.Add(3);
            items.Add(4);
            items.Add(5);

            SetVariable("items", items);

            Hashtable h = new Hashtable();
            h[0] = 1;
            h[1] = "name";
            h[2] = items;

            SetVariable("h", h);

            base.Show(windowService, objectProvider);
        }
    }
}
